<template>
  <div class="station">
    <van-nav-bar
      left-arrow
      class="title-bar"
      title="印章签名管理"
      :border="false"
      @click-left="$router.push('/my')"
    />
    <!-- 个人 -->
    <div class="personage">
      <div class="title-name">个人印章</div>
      <div class="box-content">
        <!-- 添加签名 -->
        <div class="state-personage">
          <div class="write-personage" @click="$router.push('./canvas')">
            <van-icon class-prefix="iconfont icontianjiaqianming" />
            <span>手写签名</span>
          </div>
        </div>
        <div
          class="state-personage"
          v-for="(item, index) in signature.records"
          :key="index"
        >
          <div class="write-personage" @click="sealShow = true">
            <img :src="item.sealImgData" alt="" />
          </div>
          <span class="personage-span" v-if="item.defaultFlag === 1">默认</span>
        </div>
      </div>
    </div>
    <!-- 公司 -->
    <div class="personage">
      <div class="title-name">北京华信云盛科技有限公司</div>
      <div class="box-content">
        <div
          class="state-personage"
          v-for="(item, index) in signature.records"
          :key="index"
        >
          <div class="write-personage" @click="sealShow = true">
            <img :src="item.sealImgData" alt="" />
          </div>
          <span class="personage-naem">{{ item.sealName }}</span>
        </div>
      </div>
    </div>
    <div class="content-end"><span></span>没有更多了<span></span></div>
    <!-- 弹出层 -->
    <van-popup v-model="sealShow" position="bottom" :style="{ height: '27%' }">
      <van-button class="btn-one" type="default" block>设为默认</van-button>
      <van-button class="btn-two" type="default" block>确定删除</van-button>
      <van-button
        class="btn-three"
        type="default"
        block
        @click="sealShow = false"
        >取消</van-button
      >
    </van-popup>
  </div>
</template>

<script>
import { eSignature } from '@/api/user'
export default {
  data() {
    return {
      // 印章弹出框
      sealShow: false,
      signature: {}
    }
  },
  created() {
    this.initialList()
  },
  mounted() {},
  methods: {
    async initialList() {
      try {
        const { data: res } = await eSignature(
          this.$store.state.userName.idNumber
        )
        this.signature = res.data
        console.log(this.signature)
      } catch (error) {
        console.log(error)
      }
    }
  }
}
</script>

<style scoped lang="less">
.station {
  background-color: #f8f8f8;
  .title-bar {
    height: 128px;
    width: 100%;
    padding-top: 40px;
    box-sizing: border-box;
    /deep/.van-nav-bar__title {
      font-size: 34px;
      font-weight: bold;
    }
    /deep/.van-icon {
      font-size: 48px;
      color: #000;
    }
  }
  // 个人
  .personage {
    background-color: #fff;
    padding: 0 40px;
    margin-top: 20px;
    .title-name {
      font-size: 30px;
      padding: 24px 0;
    }
    .box-content {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      .state-personage {
        height: 415px;
        .write-personage {
          width: 315px;
          height: 315px;
          background-color: #f6f6f6;
          display: flex;
          flex-direction: column;
          justify-content: center;
          align-items: center;
          margin-bottom: 8px;
          .iconfont {
            font-size: 1em;
            margin-bottom: 40px;
          }
          span {
            font-size: 30px;
            color: #b2b2b2;
          }
          img {
            width: 200px;
          }
        }
        .personage-span {
          font-size: 22px;
          padding: 7px 24px;
          border: 1px solid #8ac0f8;
          color: #8ac0f8;
          border-radius: 50px;
        }
        .personage-naem {
          font-size: 28px;
        }
      }
    }
  }
  .content-end {
    height: 117px;
    font-size: 22px;
    color: #999999;
    text-align: center;
    line-height: 117px;
    span {
      display: inline-block;
      height: 1px;
      width: 48px;
      background-color: #999999;
      margin: 0 12px;
      vertical-align: middle;
    }
  }
  // 弹出层
  .van-popup {
    background-color: #f8f8f8;
    .van-button--block {
      height: 110px;
      border-width: 0;
    }
    .btn-one {
      border-bottom: 1px solid #e4e4e4;
    }
    .btn-two {
      color: red;
    }
    .btn-three {
      position: absolute;
      bottom: 0;
      left: 0;
    }
  }
}
</style>
